package com.snowflake.ecatalog.web.profile;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.snowflake.ecatalog.service.profile.LatestService;
import com.snowflake.ecatalog.vo.LatestData;

/**
 * 获取最新的图片资源的Controller, 使用Restful风格的Urls:
 * 
 * List page : GET /background/ Create page : GET /background/create Create
 * action : POST /background/create Update page : GET /background/update/{id}
 * Update action : POST /background/update Delete action : GET
 * /background/delete/{id}
 * 
 */
@Controller
@RequestMapping(value = "/latest")
public class LatestController {

	@Autowired
	private LatestService service;

	@RequestMapping(value = "")
	public @ResponseBody
	LatestData getLatestDataByPost(@RequestParam("profileId") Long profileId) {
		return service.getLatestData(profileId);
	}

	@RequestMapping(value = "{profileId}", method = RequestMethod.GET)
	public @ResponseBody
	LatestData getLatestDataByGet(@PathVariable("profileId") Long profileId) {
		return service.getLatestData(profileId);
	}
}
